package com.tmxk.day01.lifeng.demo4;

public class Rabbit extends Pet{
	private String appearance;
	public String getAppearance() {
		return appearance;
	}

	public void setApperance(String appearance) {
		this.appearance = appearance;
	}
	public Rabbit() {
	}
	
	public Rabbit(String appearance) {
		super();
		this.appearance = appearance;
	}

	@Override
	public void shout() {
		System.out.println("兔子叫");
	}
	
	public void Rabbit() {	
	}
	
	public void run() {
		System.out.println(super.getName() + "擅长跑");
	}
	//常识:Object父类equals方法比较还是在内存地址
	//String类重写了Object父类的equals()方法
	//模拟String类中equals方法,重写Rabbit用户自定义类的equals方法
	//instanceof对象类型引用比较,判断当前传递的对象是否是指定的数据类型
	public boolean equals(Object anObject) {
		if(this == anObject) {
			return true;
		}
		//anObject instanceof Rabbit : 判断当前传递到对象引用是否是Rabbit类型
		if(anObject instanceof Rabbit) {
			Rabbit rabbit = (Rabbit) anObject;
			if(this.getName().equals(rabbit.getName())
					&&this.getAge() == rabbit.getAge()
					&&this.getStrain().equals(rabbit.getStrain())
					&&this.getAppearance().equals(rabbit.getAppearance())) {
				return true;
			}else {
				return false;
			}
		}
		return false;
	}
}
